package com.example.blog.controller;

import com.example.blog.entity.Result;
import com.example.blog.service.PhotoService;
import org.apache.ibatis.annotations.Param;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;

@RestController
@RequestMapping("/photo")
public class PhotoController {

    @Resource
    private PhotoService photoService;

    @PostMapping("/upload")
    public Result upload(@RequestParam("file") MultipartFile file, @Param("info") String info, @Param("classify") String classify){
        return photoService.upload(file, info, classify);
    }

    @DeleteMapping("/delete/{photoId}")
    public Result delete(@PathVariable("photoId") String photoId){
        return photoService.delete(photoId);
    }

    @GetMapping("/getClassPhoto")
    public Result getClassPhoto(@Param("classify") String classify){
        return photoService.getClassPhoto(classify);
    }

    @GetMapping("/getClass")
    public Result getClassify(){
        return photoService.getClassify();
    }
}
